<template>
  <div class="app-container" v-loading="pageLoading">
    <el-button type="primary" class="fr" @click="createItem" v-permission="'group.add'">创建</el-button>
    <div class="filter-container">
      <el-input style="width: 300px" placeholder="输入查询条件按回车" clearable prefix-icon="el-icon-search" class="filter-item"
        @keyup.enter.native="research" @clear="research" v-model="query.queryString"></el-input>
      <el-select class="filter-item" style="width: 200px" placeholder="是否系统控制工序" v-model="query.mes_flag" clearable
        @clear="getList" @change="getList">
        <el-option label="是" value="Y"></el-option>
        <el-option label="否" value="N"></el-option>
      </el-select>
      <el-button class="filter-item" type="success" plain @click="research">查询</el-button>
      <el-button class="filter-item" type="info" plain @click="exportData" :loading="exportLoading">导出 </el-button>
    </div>
    <z-table :list="list" :tableProps="tableProps" :columns="columns" @editItem="editItem" @deleteItem="deleteItem">
    </z-table>
    <z-pagination :pagination="pagination" :total="total" :page.sync="query.page" :limit.sync="query.size"
      @change="getList"></z-pagination>
    <z-form-dialog :name="name" :data="data" :formProps="formProps" :fields="fields" @submit="submit"
      :submitLoading="submitLoading" :visible.sync="editFormVisible"></z-form-dialog>
  </div>
</template>
<script>
import commonMixin from '@/views/_common/mixin'
export default {
  mixins: [commonMixin],
  name: 'group',
  data: function () {
    return {
      api: this.$api.group,
      apiList: this.$api.group + 'getlistbypage',
      name: '工序',
      columns: [
        { title: '工段', key: 'section_name', width: 120 },
        { title: '工序类型', key: 'type_name', width: 140 },
        { title: '工序名称', key: 'group_name', width: 180 },
        { title: '工序描述', key: 'description' },
        { title: '系统控制工序', key: 'mes_flag', width: 100 },
        { title: '修改人', key: 'modify_user', width: 100 },
        { title: '最后修改', key: 'modify_time', width: 140 },
      ],
      fields: [
        { title: '工段', key: 'section_id', span: 12, name: 'select', options: [] },
        { title: '工序类型', key: 'type_id', span: 12, name: 'select', options: [] },
        { title: '工序名称', key: 'group_name', span: 24 },
        { title: '工序描述', key: 'description', span: 24 },
        {
          title: '系统控制工序',
          key: 'mes_flag',
          span: 24,
          name: 'switch',
          props: {
            inactiveValue: 'N',
            activeValue: 'Y',
          },
        },
        { title: '备注', key: 'remarks', span: 24 },
      ],
      initData: { mes_flag: 'N' },
    }
  },
  methods: {},
  created: function () {
    this.getList()
    this.$request(this.$api.section + 'getlist').then((r) => {
      this.setFieldOptions('section_id', r.list, 'id', 'section_name')
    })
    this.$request(this.$api.groupType + 'getlist').then((r) => {
      this.setFieldOptions('type_id', r.list, 'id', 'type_name')
    })
  },
}
</script>
<style scoped>
</style>
